<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Transfer - FAQ</title>
<a href="index.html" id="nav">Home</a>
<link rel="stylesheet" type="text/css" href="default.css" />
</head>
<body>
<h1>FAQ</h1>


<p><b>What is Transfer ORM?</b></p>

<p>Transfer is a Object Relational Mapper for ColdFusion&nbsp;</p>

<br/>
<p><b>What does ORM stand for?</b></p>

<p>ORM stands for <b>O</b>bject <b>R</b>elational <b>M</b>apper<br></p>

<br/>
<p><b>What is a Object Relational Mapper?</b></p>

<p><a href="http://en.wikipedia.org/wiki/O/R_mapping">Wikipedia provides a basic explanation of Object Relational Mapping</a></p>

<br/>
<p><font color="#000000"><b>What's a TransferObject?</b></font></p>

<p><font color="#000000">A TransferObject is the name given to the Objects that are generated by Transfer on new() and get() operations.&nbsp; This is because of the name of the framework, and that they are either CFCs of type 'transfer.com.TransferObject', or they extend that type.<br></font></p>

<p><font color="#000000">This generated Object is considered a Business Object, </font><font color="#000000">i.e. a representation of a single entity, such as a Employee, or a Product </font><font color="#000000">in your application.</font></p>

<br/>
<p><b>What's the difference between ManyToOne and OneToMany?</b></p>

<p><i>OneToMany </i>composition is useful when you wish for TransferObjects on both sides of the relationship to see each other, or for the Parent to have a collection of the child objects attached to it.</p>

<p>A <i>ManyToOne </i>collection is useful when, either for application design, or performance reasons, you only want an Objects to load one side of the relationship, and not generate a collection of Objects.<br></p>

<p>For example, if I have a series of Comments on a Blog Post, I want the Post to have a collection of Comments on it, so I would use a <i>OneToMany</i>.</p>

<p>However, if I had a Product with which I could generate hundreds of Orders, I would build my Order object with a <i>ManyToOne </i>to my Product, so that a Order would have a Product attached, and the Product would have no need to be aware of it's Orders.</p>

<p><font color="#000000">In other words, you can think of <i>OneToMany </i>as One<b>With</b>Many, and <i>ManyToOne </i>as <b>one </b><b>of</b> Many<b>With</b>One.</font><br></p>

<br/><p><font color="#000000"><b>Should I use ManyToMany, or two OneToMany compositions?</b><br></font></p>

<p><font color="#000000">Use two <i>OneToMany </i>compositions
with a common child when your child object is a business object with
its own state.&nbsp; If the association table holds nothing but the two
foreign keys, use <i>ManyToMany</i>.</font></p>


<br/><p>
<b>How do I get Transfer working with ColdSpring?</b>
</p>
<p>There are several ways to get Transfer working with ColdSpring, the simplest ColdSpring configuration is the following:<br></p>

<p><font face="courier new,monospace">&lt;bean id="transferFactory" class="transfer.TransferFactory" singleton="true" &gt;<br>&nbsp;&nbsp;&nbsp; &lt;constructor-arg name="datasourcePath"&gt;&lt;value&gt;/myapp/configs/datasource.xml&lt;/value&gt;&lt;/constructor-arg&gt;</font></p>

<p><font face="courier new,monospace">&nbsp;&nbsp;&nbsp; &lt;constructor-arg name="configPath"&gt;&lt;value&gt;/myapp/configs/transfer.xml&lt;/value&gt;&lt;/constructor-arg&gt;&nbsp; </font></p>

<p><font face="courier new,monospace">&nbsp;&nbsp;&nbsp; &lt;constructor-arg name="definitionPath"&gt;&lt;value&gt;/myapp/definitions&lt;/value&gt;&lt;/constructor-arg&gt;<br>&lt;/bean&gt;<br>&nbsp;&nbsp;&nbsp; <br>&lt;bean id="transfer" factory-bean="transferFactory" factory-method="getTransfer" singleton="true" /&gt;<br>&lt;bean id="datasource" factory-bean="transferFactory" factory-method="getDatasource" singleton="true" /&gt;</font><br></p>

<p>This enables&nbsp;the <a href="cfcdoc/content2efb.html">Datasource CFC</a>, and the <a href="cfcdoc/content3c54.html">Transfer CFC</a> to be available for injection by ColdSpring.</p>

<p>It is also possible to integrate Transfer with ColdSpring using the <a href="cfcdoc/content1186.html">Configuration CFC</a>, if a more dynamic approach is required, more details of which can be found in the <a href="installation.html">installation documentation</a>.</p>

<br/><p><b>How do I get Transfer working with LightWire?</b></p>

<p>As of LightWire 0.01, the simplest way to get Transfer working with LightWire is to set up the LightWire configuration file as follows:</p>



<p><font face="courier new,monospace">variables.Bean.transferFactory.Singleton = 1;<br>variables.Bean.transferFactory.Path = "transfer.transferFactory";<br>variables.Bean.transferFactory.ConstructorProperties.datasourcePath = "/#application.name#/config/datasource.xml";<br>variables.Bean.transferFactory.ConstructorProperties.configPath = "/#application.name#/config/transfer.xml";<br>variables.Bean.transferFactory.ConstructorProperties.definitionPath = "/#application.name#/model/definitions";</font></p>



<p><font color="#cccccc"><font color="#000000">In order for this to work you may need to create a mapping with the logical path "transfer" pointing to the transfer folder, depending on your version of Lightwire.</font><b></b></font></p>
<br/><p><b>I keep getting the error: 'The argument XMLFILEREADER passed to function init() is not of type <br>transfer.com.io.XMLFileReader.'&nbsp; (or something similar). What does this mean?</b></p>

<p>This is generally a sign that Transfer hasn't been installed correctly. Transfer must be installed in the web root. To place it anywhere else, you must use mappings. Please see the <a href="installation.html">documentation on installation</a> before continuing.<br></p>



<br/><p><font color="#000000"><b>I keep getting database errors with repeated field names in the select list</b></font></p>

<p><font color="#000000">When you set up a <i>OneToMany </i>or <i>ManyToOne </i>composition relationship, don't include the foreign key field in the list of properties for the parent table.</font><br></p>



<br/><p><b>Is Transfer a Dependency Injector (DI) Engine?</b></p>

<p>No. Transfer does not manages DI or ioC (Inversion of Control). It is an ORM framework and not a DI Engine. For DI/ioC refer to ColdSpring or LightWire. Transfer does have the ability to inject dependencies into Transfer Objects (see this <a href="http://transfer.riaforge.org/index.cfm?event=page.issue&amp;issueid=E7961709-9517-FB71-7F1434A87BBBFD11">Enhancement</a> for more details), but this should not be confused with DI/ioC.<br></p>

<br/><p><b>How do I inject dependencies into a TransferObject?</b></p>

<p>To inject dependencies into a TransferObject, the 'afterNew' event must be used.&nbsp;</p>

<p>To register an Observer for the afterNew event:&nbsp;</p>

<p><font face="courier new,monospace">observer = createObject("component", "InjectorObserver").init();&nbsp;</font></p>

<p><font face="courier new,monospace">getTransfer().addAfterNewObserver(observer);&nbsp;</font></p>

<p>The observer <b>must </b>have a method on it that looks like, which is run when the event is fired:&nbsp;</p>

<p><font face="courier new,monospace">&lt;cffunction name="actionAfterNewTransferEvent" hint="Do something on the new object" access="public" returntype="void" output="false"&gt; <br> &nbsp; &nbsp; &lt;cfargument name="event" hint="" type="transfer.com.events.TransferEvent" required="Yes"&gt; <br> &nbsp; &nbsp; &lt;!--- do stuff here ---&gt; <br> &lt;/cffunction&gt;&nbsp;</font></p>

<p>The event is then fired *after* the TransferObject is init()'d and the configure() method is run.&nbsp;</p>

<p>So if you now want to inject something into a TransferObject, you will need to write a setter/getter on it - and you can do it something like this: <br></p>

<p><font face="courier new,monospace">&lt;cffunction name="actionAfterNewTransferEvent" hint="Do something on the new object" access="public" returntype="void" output="false"&gt; <br> &nbsp; &nbsp; &lt;cfargument name="event" hint="" type="transfer.com.events.TransferEvent" required="Yes"&gt; <br> &nbsp; &nbsp; &lt;cfif arguments.event.getTransferObject().getClassName() eq "user.User"&gt; <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;cfset arguments.event.getTransferObject().setService(getService()) /&gt; <br> &nbsp; &nbsp; &lt;/cfif&gt; <br> &lt;/cffunction&gt;&nbsp;</font></p>



<p>A &lt;cfcase&gt; statement could be used instead of an &lt;cfif&gt; depending on your needs.</p>



<p>You could put this event directly on a Factory of some description if you&nbsp; wanted to, or have it on a specific object whose only task is to inject new <br> TransferObjects with dependencies, depending on your application design.<br></p>

<br/><p><b>Does Transfer generate any files?</b></p>

<p>Yes, Transfer does generate files, however it doesn't generate .CFC files.&nbsp; Transfer generates files with the extension .transfer that are utilised by Transfer for building its generic TransferObjects at runtime to represent the Business Objects in your application.<br></p>

<p>So while Transfer handles generating your Business Objects for you at run time, it does not generate DAO's, Gateways, or Service Layer CFCs for you.&nbsp; This is so that you have complete freedom in how you develop and design your application, and are not tied to a specific development structure.</p>

<br/><p><font color="#000000"><b>My application seems to be using a lot of memory since I started using Transfer</b></font></p>

<p><font color="#000000">By default transfer will cache indefinitely every object it creates.&nbsp; However, it will give memory back if the JVM needs it.&nbsp; See the <a href="caching.html">documentation on caching</a>.</font></p>

<p><font color="#000000">If you see a big instantaneous memory hit, check your composition relationships. When loading a TransferObject with a <i>OneToMany </i>or a <i>ManyToMany </i>relationship, Transfer will normally load all of its children as well (and their children etc...).&nbsp;&nbsp;</font></p>



<p><font color="#000000">If this is a problem, you can control it with the <a href="lazy.html">"lazy" configuration attribute</a>, or, if the composition is <i>OneToMany</i>, you can change the relationship to <i>ManyToOne</i>.</font></p>



<p><font color="#000000">You can also configure multiple aspects of the cache to limit the number of TransferObjects that are cached, how long they are cached for, and what scope they a cached in.&nbsp; Which configuration options you use is greatly influenced by your application design, and it may not need to be configured at all.&nbsp; More details on the caching options can be found in the <a href="caching.html">Caching</a> and <i><a href="transfer.doc.html#objectCache">objectCache</a></i> sections of the Transfer file configuration documentation.</font></p>



<p><font color="#000000">For example, if I want to limit a TransferObject of class 'user.User' to only be cached within the request of the page, I could set it up like this, within my <i>objectCache </i>element in my configuration file.</font></p>



<p><font color="#000000" face="courier new,monospace">&lt;cache class="user.User"&gt;<br>&nbsp;&nbsp; &lt;scope type="request"/&gt;<br>&lt;/cache&gt;</font></p>

<br/><p><font color="#000000"><b>What is Clone() good for? Why would I want to Clone() a TransferObject?</b></font></p>

<p><font color="#000000">Cloning is very useful when you want to make changes to an object, but you don't want those changes reflected in the cache until you save the object back to the database.</font></p>

<p><font color="#000000"></font>The primary example of this is in validation of an object.&nbsp; Say for example, you get() a User from the database, and you are populating it with form data, you may not know if the data in the User object is valid or not, until you call User.validate(), but if you make changes to the User object that just came out of cache, it is possible that invalid data would be visible across your application.</p>



<p>To avoid this issue, you can create a clone() of your User, by calling:</p>

<p><font face="courier new,monospace">cloneUser = User.clone();</font><br></p>

<p>This creates a new User which is a clone of the original.&nbsp; Changes can be made to the clone quite happily, without having to worry about them being visible across your cache.&nbsp; So that means you can call .validate() on the cloneUser, and check to see if the data is valid before saving it.<br></p>

<p>When the cloneUser is saved, it's state is synchronised with the original User that came from the cache, thus ensuring that only valid data is visible across the cache.</p>

<br/><p><font color="#000000"><b>I get an error "The requested object could not be found in the config file"</b></font></p>

<p><font color="#000000">This error occurs when Transfer can't find the <i>object</i> element that matches a given class name in the XML configuration file.</font></p>


<p><font color="#000000">The first things to do when solving this problem are:</font></p>

<ol>
<li>
Double check that the <i>package</i> and <i>object </i>names match with the class you are requesting</li>

<li>Remember that the class name is CaSe SenSitive, so make sure that you have 'user.User' and not 'User.user'</li>

<li>Validate your configuration file against the provided XML Schema, there may be a typo somewhere.</li>
</ol>
<br/><p><font color="#000000"><b>How do I validate my configuration file?</b>&nbsp;</font></p>

<p><font color="#000000">First of all, you need to get an XML editor, a good list can be found in the <a href="gettingStarted.html">Getting Started</a> section&nbsp;</font></p>

<p><font color="#000000">Then, in your XML file, you need to make sure that your</font><font color="#000000"> xsi:noNamespaceSchemaLocation attribute in the configuration file has a valid path to the transfer.xsd file. </font><font color="#000000"><br></font></p>

<p><font color="#000000">To make life easier, you may wish to copy the XSD file into the same directory as your XML files, so it is easy to reference.</font><br></p>


An overview of general XML can be found on <a href="http://en.wikipedia.org/wiki/XML">wikipedia</a><font color="#993399">&nbsp;</font><br>
<br/>

<p><b>I just updated&nbsp; Transfer, and now I'm getting the
error: 'The method 'xxx' could not be found in component
TransferObject.cfc.', help?</b></p>
<p>Generally this is caused because you haven't deleted your
.transfer files that were generated by the previous version of Transfer.</p>
<p>Whenever you update Transfer it is important that you delete the
previous version's .transfer files, as they may contain code that won't
work with this version.</p>
<p>For more information on updating Transfer see <a
	href="http://www.compoundtheory.com/transfer/documentation/installation.html">Installing
and Updating</a>.</p>

</body>
</html>